package com.spzx.cart.api.fallback;

import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.api.domain.CartInfo;
import com.spzx.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * ClassName: RemoteCartFallbackFactory
 * Description:
 *
 * @Author linz
 * @Creat 2025/3/19 21:32
 * @Version 1.00
 */
@Slf4j
public class RemoteCartFallbackFactory implements FallbackFactory<RemoteCartService> {
    @Override
    public RemoteCartService create(Throwable cause) {
        log.info("获取用户购物车选中商品数据失败:{}",cause.getMessage());
        return new RemoteCartService() {
            @Override
            public R<List<CartInfo>> getCartCheckedList(String source) {
                return R.fail("获取用户购物车选中商品数据失败" + cause.getMessage());
            }
        };
    }
}
